let arr = ["username", "password"];
console.log("请输入" + arr[0] + ":");
let msg = {};
let index = 0;
process.stdin.on("data", (data) => {
    let info = data.toString();
    msg[arr[index++]] = info;
    if (index == arr.length) {
        //输出未加密的
        console.log(msg);
        let msgStr = msg.username + ":" + msg.password;
        //将字符串转换得到buffer实例
        let buf = Buffer.from(msgStr, "utf-8");
        //将buffer实例进行编码转换成base64字符串
        let base64Str = buf.toString("base64");
        //输出加密后的用户名和密码
        console.log("base64加密" + base64Str);
        process.exit();
    }
    console.log("请输入" + arr[index] + ":");
})
